package com.saop;

import com.tools.HttpClientUtil;

import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 报竣小工具
 */
public class ArchiveGrpTask {

   void   task() {
         String tasks = "510000511028:8410100,\n" +
                 "510000449037:8410100,\n" +
                 "510000492032:8410100,\n" +
                 "510000491036:8410100,\n" +
                 "510000511030:8410100,\n" +
                 "510000493034:8410100,";

       String[] split = tasks.split(",");

    //   ExecutorService executorService = Executors.newCachedThreadPool();
       ExecutorService executorService = Executors.newFixedThreadPool(4);

       for (int i = 0; i < split.length; i++) {
           executorService.submit(new Archive(split[i]));
       }

       executorService.shutdown();
       System.out.println("结束");
   }


    class Archive implements Runnable {

       private String task;

        Archive(String task) {
            this.task = task;
        }

        @Override
        public void run() {
String url ="http://137.32.148.228:9700/saop-service/service/saop_exchange";
            String[] split = task.split(":");
            String  json = "{" +
                    "    \"contractRoot\": {" +
                    "        \"svcCont\": {" +
                    "            \"feedbackReq\": {" +
                    "                \"coId\": \""+split[0]+"\"," +
                    "                \"lanId\": \""+split[1]+"\"" +
                    "            }" +
                    "        }," +
                    "        \"tcpCont\": {" +
                    "            \"appKey\": \"SF00000017\"," +
                    "            \"dstSysId\": \"SF00000000\"," +
                    "            \"reqTime\": \"2018-07-20 10:41:30\"," +
                    "            \"sign\": \"***\"," +
                    "            \"svcCode\": \"usb.orderFeedback\"," +
                    "            \"transactionId\": \"JL00000018201807202054490289\"," +
                    "            \"version\": \"V1.0\"" +
                    "        }" +
                    "    }" +
                    "}";
            HashMap<String, String> stringStringHashMap = new HashMap<String, String>();
            String doPost = HttpClientUtil.doPost(url, json, "UTF-8", 3000, stringStringHashMap);
            System.out.println(doPost);
        }
    }

/*
    public static void main(String[] args) {
        new ArchiveGrpTask().task();

    }*/
}
